home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-09-07 | 4.8 KB | 145 lines | [TEXT/KAHL] |
- ` Binary
- ` Uses state-of-the-art binary targeting algorithm. Also pops to top
- ` level if target "disappears".
-
- ` Changed in v. 1.1: when swiveling to the right, we go 1 degree
- ` further than twice the scanwidth. This keeps regions disjoint.
-
- ` v. 1.1a3 based directly off of 1.1a. Once the scanwidth is
- ` reasonably small, checks to see if has achieved a fortuitous
- ` lock.
-
- ` v.1.2 Treats its first shot as a "test" for decoys before firing for
- ` effect. Also bases tightscan on range using a rough guess based on experiment.
-
- ` v.1.3 is same as 1.2 except that tightscan guesses are based on
- ` a precise calculation of target's angular width and a notion
- ` that a 1/n chance of being lucky is worth taking when you have
- ` >=n swivels to go before a "guaranteed" lock.
-
- ` v.1.3a is more "greedy". It is based on a notion that a 1/n chance
- ` of being luckyis worth taking when you have >= n/2 swivels to go
- ` before a guaranteed lock. This is because each swivel is a swival
- ` and a ping, i.e. two turns.
-
- ` v 1.4 incorporates modifications for dealing with floating point
- ` math. (Essentially, this involves changing "=0" to "<1" on one line
- ` and making sure another line is rounded properly. (Note that we
- ` still haven't tested for the "missing degree" bug, which originally
- ` made me find the discontinuous robot bug in RB.) Also fixes a
- ` branching error: the program should now initiate tightscan checks
- ` earlier when at a close range.
-
- ` v 1.4a incorporates an additional floating point correction by
- ` changing =0 to <1 in the line before checking for tightscans.
-
- ` v 1.4b does a total of three objectscan 0's before starting over.
- ` This is slightly wasteful, but much less so than starting over
- ` when only 1 degree away from a lock, which the current algorithm
- ` allows. Note that the introduction of FP math has introduced a
- ` new side effect (as of 8/6/91) in that swivel -0.5 is the same as
- ` swivel -1 (provided headfacing isn't 0). To some extent this is an
- ` advantage because it *appears* that a target at the extreme left of
- ` a scan would otherwise never be found.
-
- ` v 1.4c uses TRUNC to do away with the side effect, and compensates
- ` by doing the last few objectscans correctly.
-
- ` v 1.4d has a fix for tightscan. At ranges greater than 78, tightscan
- ` is 8 instead of 16. (Ranges can go up to 106, which I forgot.)
-
- equip 4 0 0 0 0 300
-
- ` tightscan is the maximum width at which the computer will see
- ` if it got lucky. (This requires an extra scan, so it may not be
- ` worth it if you only have a rough idea where the enemy is located.)
-
- let TRUE = 1
- let FALSE = 0
- let left = TRUE
-
- ` Search 128-degree arcs until a target is located.
-
-
- 5 let scanwidth = 64
- 7 let swivelamt = 129
- 10 objectscan scanwidth
- 20 if range > 0 then goto 50
- 30 swivel swivelamt
- 40 goto 10
-
- ` Target found. Are we accurate enough to fire?
-
- 50 if scanwidth < 1 then goto 500
- 51 let tightscan = 64
- 52 if range > 26 then let tightscan = 32
- 53 if range > 46 then let tightscan = 16
- 54 if range > 78 then let tightscan = 8
- 56 if scanwidth > tightscan then goto 100
- 57 objectscan 0
- 60 if range > 0 then goto 500
-
- ` Not accurate enough...
- ` Narrow in by scanning left half of known arc.
-
- 100 let left = TRUE
- 105 let scanwidth = scanwidth / 2
- 110 let swivelamt = scanwidth + .5
- 115 let swivelamt = TRUNC swivelamt
- 117 let swivelamt = 0 - scanwidth
- 120 swivel swivelamt
- 130 objectscan scanwidth
- 140 if range > 0 then goto 50
-
- ` Not in left half. If scanwidth is zero, we should only do one or two
- ` more scans.
-
- 145 if scanwidth < 1 then goto 200
-
- ` Otherwise, let's treat the right half as the new known arc.
-
- 160 let left = FALSE
- 162 let swivelamt = 3 * scanwidth
- 165 let swivelamt = swivelamt/2
- let swivelamt = TRUNC swivelamt
- 166 let swivelamt = swivelamt + 1
- 167 let scanwidth = scanwidth/2
- 170 goto 120
-
- ` Last scan(s) before starting over. If we find him here, shoot.
- ` Otherwise, start over with wide angle scan.
-
- 200 swivel 1
- 210 objectscan 0
- 220 if range > 0 then goto 500
- 230 if left = FALSE then goto 5
- 240 let left = FALSE
- 250 goto 200
-
- ` Now scans immediately after the first zap before doing zap zap.
- ` Also expends a minimum of energy on the first zap to avoid expending
- ` energy on decoys. (Note: we could do a humanscan, but that wouldn't
- ` be worth it unless we know there are a lot of humans about. That
- ` could be checked at the beginning of the game with a humanscan 180.)
- ` Also note that it may not be worth it to cripple the first zap,
- ` thus effectively warning the target.
-
- ` *Also* checks to see if target is friendly. If so, restarts scan
- ` in such a way as to avoid locking on target again. (In practice,
- ` robots could inform each other of their locations to avoid confusing
- ` each other.)
-
- 500 if ENEMY = 0 then goto 600
- 501 zap 1
- 502 objectscan 0
- 503 if range = 0 then goto 5
- 505 zap
- 507 zap
- 510 objectscan 0
- 520 if range > 0 then goto 505
- 530 goto 5
-
- 600 let scanwidth = 64
- 610 let swivelamt = 129
- 620 goto 30
-